//ACCEPTED
#include <cstdio>
#define MAX(a,b) a>b?a:b
int t[100][100][100], n, i, j, k, sum = -1000, s;
void read(){
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d", &t[0][i][0]);
		s=t[0][i][0];
		if(s>sum)sum=s;
		for(j=1;j<n;j++){
			scanf("%d", &t[0][i][j]);
			s = MAX(t[0][i][j],t[0][i][j]+s);
			if(s>sum)sum=s;
		}
	}
}
void process(){	
	for(k=1;k<n;k++){
		for(i=k;i<n;i++){
			t[k][i][0]=t[k-1][i-1][0]+t[0][i][0];
			s = t[k][i][0];
			if(s>sum)sum=s;
			for(j=1;j<n;j++){
				t[k][i][j]=t[k-1][i-1][j]+t[0][i][j];
				s = MAX(t[k][i][j],t[k][i][j]+s);
				if(s>sum)sum=s;
			}
		}
	}
	printf("%d\n", sum);
}
int main(){
	read();
	process();
	return 0;
}
